﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebPart.aspx.cs" Inherits="Cms.Web.CmsSystem.SysModules.Portal.WebPart" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="/App_Themes/default/CoreEdit.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="/Scripts/core.js" type="text/javascript"></script>
    <script src="/Scripts/json.js" type="text/javascript"></script>
    <link href="/App_Themes/Default/easyui/easyui.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/easyui/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="/Scripts/form.js" type="text/javascript"></script>    
    <script src="/Scripts/kindeditor/kindeditor-min.js" type="text/javascript"></script>
    <script src="/Scripts/kindeditor/lang/zh_CN.js" type="text/javascript"></script>
    <script type="text/javascript">
        var wptType=<%= JsWpttype%>;
        var dtsType=<%= JsDataSourcetype%>;
        var keditor;
        function Save(callback) {   
            if(keditor)      
                keditor.sync();              
            var json = $("form").serializeArray();
            formSubmit("Webpart", null, callback);
        }
        function loadKindEditor(){
              $("[name=SCRIPTTYPE]").trigger("change");
                    keditor =KindEditor.create('[name=TEMPLATE]', {
					themeType : 'qq',
					items : [
						'bold','italic','underline','fontname','fontsize','forecolor','hilitecolor','plug-align','plug-order','plug-indent','link'
					]
				});
        }
        
        $(function() {
            var recordid = "<%=RecID %>";
            var action = "<%=Action %>";
            var w = GetInnerWidth();
            var h = GetInnerHeight();
            $("#tabs").css({ width: w + "px", height: h-20 + "px" }).tabs();
            $("#TEMPLATE").css({ width: "99%", height: (h - 90) + "px", "overflow": "auto", "border": "0", "margin": "0", "padding": "0" });
            $("#SERVERSCRIPT").css({ width: "99%", height: (h - 60) + "px", "overflow": "auto", "border": "0", "margin": "0", "padding": "0" });

            if (action == "add") {
                $("#ID").val(recordid);
                loadKindEditor();
            }
            else if (action == "modify") {
                formLoad("Webpart", recordid,null,function(){
                  loadKindEditor();
                });
            }
            var showTab=function(title,isshow){
                var tb=$('#tabs').tabs('getTab',title)
                if(!tb)
                    return false ;
                var tab_option = tb.panel('options').tab;
                if(isshow )
                    tab_option.show()
                else
                    tab_option.hide();
            }                            
					
            $("[name=SCRIPTTYPE]").bind("change", function() {
                var v = $(this).val();
                if(v==dtsType.None){					
                    showTab("数据源",false);                    
                }    
                else{                
                    showTab("数据源",true);                   
                }
            });
            });
           
    </script>
</head>
<body style="margin: 0; padding: 0;">
    <form id="form1" runat="server">
    <div id="tabs">
        <div title="基本信息">
            <div class="row">
                <label class="label">
                    代码:</label>
                <label class="input">
                    <input type="text" name="ALIAS" />
                    <input type="hidden" name="ID" id="ID" />
                </label>
            </div>
            <div class="row">
                <label class="label">
                    名称:</label>
                <label class="input">
                    <input type="text" name="TITLE" /></label>
            </div>
            <div class="row">
                <label class="label">
                    类型:</label>
                <label class="input">
                    <select name="WEBPART_TYPE">
                        <%=WptOptions%>
                    </select>
                </label>
            </div>
            <div class="row">
                <label class="label">
                    数据源类型:</label>
                <label class="input">
                    <select name="SCRIPTTYPE">
                        <%=DtsOptions%>
                    </select>
                </label>
            </div>
            <div class="row">
                <label class="label">
                    外观:</label>
                <label class="input">
                    <input type="checkbox" name="ALLOW_MAX" id="ALLOW_MAX" />
                    <label for="ALLOW_MAX">
                        允许最大</label>
                    <input type="checkbox" name="ALLOW_MIN" id="ALLOW_MIN" /><label for="ALLOW_MIN">允许最小</label>
                    <input type="checkbox" name="ALLOW_CLOSE" id="ALLOW_CLOSE" /><label for="ALLOW_CLOSE">允许关闭</label>
                    <input type="checkbox" name="ALLOW_MOVE" id="ALLOW_MOVE" /><label for="ALLOW_MOVE">允许移动</label>
                </label>
            </div>
        </div>
        <div title="数据源">
            <textarea name="SERVERSCRIPT" id="SERVERSCRIPT">
            </textarea>
        </div>
        <div title="模板/内容">
            <textarea name='TEMPLATE' id="TEMPLATE"></textarea>
        </div>
    </div>
    </form>
</body>
</html>
